<!--
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2022-07-04 09:50:51
 * @LastEditTime: 2024-07-23 16:14:35
 * @LastEditors: 赵大壮
-->
<template>
  <div class="w-full h-full flex flex-col">
    <div class="w-full flex flex-col">
      <div class="flex justify-between items-center">
        <el-page-header @back="$router.back()" content="基础信息管理">
        </el-page-header>

        <div class="flex">
          <el-select
            class="mr-w20"
            v-model="s_inves.m_req.id"
            placeholder="请选择问卷"
            clearable
            @change="action_select_change"
          >
            <el-option
              v-for="item in s_inves.list_inv"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
          <el-input
            class="w-w1/3"
            placeholder="请输入问题名称"
            clearable
            v-model="s_inves.str_key"
            prefix-icon="el-icon-search"
            @change="action_list_base"
          >
          </el-input>
          <el-button
            type="primary"
            class="bg-cmain_hover ml-w10"
            @click="action_list_base"
            >搜索</el-button
          >
          <el-button
            type="primary"
            class="bg-cmain_hover ml-w10"
            icon="el-icon-plus"
            @click="dialog_add_base = true"
          >
            添加问卷问题</el-button
          >
          <el-button
            type="primary"
            icon="el-icon-notebook-2"
            @click="dialog_add_template = true"
            :class="
              s_inves.m_template_question.list_question.length != 0
                ? 'bg-cmain_hover'
                : ''
            "
            :disabled="s_inves.m_template_question.list_question.length == 0"
          >
            创建模板</el-button
          >
        </div>
      </div>
      <el-divider class="mb-w10"></el-divider>
    </div>
    <el-table
      class="w-full"
      :data="s_inves.list_inv_question"
      stripe
      height="500"
      @selection-change="action_table_selected"
    >
      <el-table-column type="selection" min-width="5%"> </el-table-column>
      <el-table-column type="index" label="序号" min-width="5%">
      </el-table-column>
      <el-table-column prop="name" label="问卷问题名称" min-width="20%">
      </el-table-column>
      <el-table-column prop="inputTypeStr" label="填写方式" min-width="10%">
      </el-table-column>
      <el-table-column prop="listCoverUrl" label="选项内容" min-width="45%">
        <template slot-scope="scope">
          <el-tag
            class="mr-w5"
            v-for="(item, index) in scope.row.contentList"
            :key="index"
            effect="plain"
            >{{ item }}</el-tag
          >
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="15%">
        <template slot-scope="scope">
          <el-button size="mini" @click="action_can_edit(scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            style="background-color: #f56c6c"
            type="danger"
            @click="action_del_base(scope.row.id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <UiDialogAddBase
      :is_showDialog="dialog_add_base"
      type="2"
      @nydialog_closed="dialog_add_base = false"
      @nydialog_submit="action_add_base"
    ></UiDialogAddBase>

    <UiDialogEditBase
      :is_showDialog="s_inves.dialog_edit_base"
      @nydialog_closed="s_inves.dialog_edit_base = false"
      :data="s_inves.m_inv_question_edit"
      @nydialog_submit="action_update_base"
    ></UiDialogEditBase>

    <UiDialogAddTemplate
      :is_showDialog="dialog_add_template"
      @nydialog_closed="dialog_add_template = false"
      @nydialog_submit="action_add_template"
    >
    </UiDialogAddTemplate>
  </div>
</template>

<script src="./Index.ts"></script>
<style src="./Index.less" lang="less" scoped>
</style>
